#include <FindCameraManipulatorByIdVisitor.h>
#include <SceneViewerFunctions.h>
FindCameraManipulatorByIdVisitor::FindCameraManipulatorByIdVisitor()
{
	
	_finded_camera_mani = NULL;
}

FindCameraManipulatorByIdVisitor::~FindCameraManipulatorByIdVisitor()
{

}



void FindCameraManipulatorByIdVisitor::apply( osgViewer::Viewer& viewer )
{
	_finded_camera_mani = NULL;
	int i=0;
	int camera_mani_size = SceneViewerFunctions::getCameraVectorSize();
	for (i = 0 ;i < camera_mani_size;i++)
	{
		osg::ref_ptr<osgGA::CameraManipulator> cam_mani_ptr = SceneViewerFunctions::sceneViewerGetCameraManipulator(i);
		if (SceneViewerFunctions::osgObjectGetDescription(cam_mani_ptr, "id") == _id_string)
		{
			_finded_camera_mani = cam_mani_ptr;
			return;
		}

	}

}

void FindCameraManipulatorByIdVisitor::setIdString( const std::string& id_string )
{
	_id_string = id_string;
}

osg::ref_ptr<osgGA::CameraManipulator> FindCameraManipulatorByIdVisitor::getFindedCameraManipulator()
{
	return _finded_camera_mani;
}
